*2_Wellman___APSR___merge
*July 21, 2020

***********************************
*This File creates Wellman_APSR_full_working.dta and Wellman_APSR_reduced_working.dta using Wellman_APSR_base plus data files created by Wellman_APSR_clean.do
***********************************

* Set the working directory to the main folder with the data files

**********************************

use Wellman_APSR_base.dta, clear
//use"/Users/bethwellman/Dropbox/DiasporaVoteData/Analysis/APSR_replication/Wellman_APSR_base.dta", clear


*Political Regime (Polity5, polity2)
merge m:m stateid year using Polity2p5.dta 
drop politycode
drop if _m==2 
drop _m

*State Capacity (ICTD UNU WIDER 2020, rev_ex_gr_ex_sc)
merge m:m stateid year using ICTD.dta 
drop reg
drop if _m==2
drop _m

*Former Portuguese or French Colony (Treisman 2007, frencol spanporc)
merge m:m stateid using FormerColony.dta
drop if _m==2
drop _m

*EMB capacity (VDem v10, v2elembcap)
merge m:m stateid year using VDem 
drop if _m==2
drop country_name _m

*Proportional Representation and Executive Party (DPI 2017, pr execme)
merge m:m stateid year using DPI2017cleaned.dta
drop if _m==2 
drop dpicode _m

*Democratic Transition (Acemoglu et al 2019, yeardem)
merge m:m stateid year using Yeardem.dta
drop if _m==2
drop wbcode _m
replace yeardem=0 if yeardem==.

*Relative Diaspora Size and Diaspora Dependence*
merge m:m stateid year using WDI_Remit_Diaspora.dta
drop wdicode
drop if _m==2
drop _m

save Wellman_APSR_full_working.dta, replace

clear
use Wellman_APSR_full_working.dta

*Dropping legislative elections from same day/same year and missing elections (n=141 to n=114 to n=107)
drop if country=="Namibia" & strpos(electionid, "L1") > 0
drop if country=="Mozambique" & strpos(electionid, "L1") > 0 & year>=2004
drop if country=="Guinea-Bissau" & strpos(electionid, "L1") > 0 & year==2014
drop if country=="Ghana" & strpos(electionid, "L1") > 0
drop if country=="Sierra Leone" & strpos(electionid, "L1") > 0
drop if country=="Burundi" & strpos(electionid, "L1") > 0 & year==2010
drop if country=="Burundi" & strpos(electionid, "L1") > 0 & year==2015
drop if country=="Cape Verde" & strpos(electionid, "L1") > 0 & year==2001
drop if country=="Cape Verde" & strpos(electionid, "L1") > 0 & year==2006
drop if country=="Cape Verde" & strpos(electionid, "L1") > 0 & year==2011
drop if country=="Congo" & strpos(electionid, "L1") > 0 & year==2002
drop if country=="Mali" & strpos(electionid, "L1") > 0 & year==1992
drop if country=="Mali" & strpos(electionid, "L1") > 0 & year==1997
drop if country=="Mali" & strpos(electionid, "L1") > 0 & year==2002
drop if country=="Mali" & strpos(electionid, "L1") > 0 & year==2007
drop if country=="Mali" & strpos(electionid, "L1") > 0 & year==2013
drop if country=="Rwanda" & strpos(electionid, "L1") > 0 & year==2003
drop if country=="Senegal" & strpos(electionid, "L1") > 0 & year==1993
drop if country=="Senegal" & strpos(electionid, "L1") > 0 & year==2007
drop if country=="Senegal" & strpos(electionid, "L1") > 0 & year==2012 
drop if Ext_voting==.e 

save "Wellman_APSR_reduced_working.dta", replace



